from registration.signals import user_registered

from brispon.models import SiteUser, info
from brispon.forms import SiteUserForm
from brispon import brispon_setting as bs
from brispon.util.sms import send

def user_created(sender, user, request, **kwargs):
    form = SiteUserForm(request.POST)
    site_user = SiteUser(user=user.user)
    site_user.mobile = form.data['mobile']
    site_user.id = user.user.id
    site_user.save()
    MSG = getattr(bs, 'CREATE_MSG', 'Activate your http://brisbanecoupon.com activation key : %s - you have 3 days.')
    msg = MSG % str(user.activation_key)
    send(site_user.mobile, msg)
    info('Created new account - %s' % (user.user.username))
    
user_registered.connect(user_created)
